/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.acworks.acroute;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author nikita
 */
public enum SpaceType {

    /**
     * INTAKE VALVE ROOM: space where our ducts start
     */
    START_SPACE(2),
    /**
     * room that we own, through which our ducts have to pass exactly once
     */
    OWNED_ROOM(0),
    /**
     * room owned by someone else
     */
    FOREIGN_ROOM(1),
    /**
     * AC ROOM: duct termination point
     */
    END_SPACE(3);
    final private int spaceCode;
    private static final Map<Integer, SpaceType> lookup = new HashMap<Integer, SpaceType>();


    static {
        for (SpaceType s : EnumSet.allOf(SpaceType.class)) {
            lookup.put(s.getSpaceCode(), s);
        }
    }

    SpaceType(int code) {
        if (code < 0 || code > 3) {
            throw new IllegalArgumentException("illegal space code: " + code);
        }
        spaceCode = code;
    }

    public static SpaceType get(int code) {
        return lookup.get(code);
    }

    public int getSpaceCode() {
        return spaceCode;
    }
}
